# -*- coding: utf-8 -*-
#===================================================
# @Time : 2021/3/16 8:48                           
# @Author : weni09                                  
# @File : schemas.py
#===================================================

from pydantic import BaseModel
from typing import Optional,List


class ArticleBase(BaseModel):
    title: Optional[str] = None
    summary: Optional[str] = None
    body: Optional[str] = None
    author_id: Optional[int] = None
    category_id: Optional[int] = None

class ArticleCreate(ArticleBase):
    img_link: Optional[str] = None
    is_public: Optional[bool]
    is_top: Optional[bool]
    body_md: str
    selectedTags:Optional[list]=[]
    art_id:Optional[int]=None
class ArticleViewsUpdate(BaseModel):
    id: int
    views: Optional[int]
    class Config:
        orm_mode = True
class Article(ArticleBase):
    id: int
    slug: Optional[str] = None
    is_public: Optional[bool] = None
    is_top: Optional[bool] = None
    img_link: Optional[str] = None
    create_date: Optional[str] = None
    update_date: Optional[str] = None
    views: Optional[int] = None
    class Config:
        orm_mode = True

class CommentAdd(BaseModel):
    article_id: int
    nickname: str
    email: str
    content: str
    content_md: str
    parent_id: Optional[int] = 0
    root_id: Optional[int] = 0

class AboutBase(BaseModel):
    id: int
    content_md: str
    content:Optional[str]=None

class UserRegister(BaseModel):
    username: str
    nickname: str
    password: str